package za.org.jcicada.comms;

/**
 * Provides a simple interface for asynchronous message arrival.
 * 
 * @author Ernst van Graan
 */

import za.org.jcicada.comms.messages.CommsMessage;

/**
 * Interface describing objects that listen to katcomms messages.
 */
public interface IMessageListener {

    /**
     * Notify the listener that a message has been received.
     *
     * @param message  Byte array representing one complete message.
     * @throws anything could happen in handler so be prepared!
     */
    public void onMessage(CommsMessage message) throws Exception;

    /**
     * Notify the listener the queue it is attached is about to be or
     * has been closed. If possible this will be called <em>before</em>
     * the queue is closed, but if the queue is terminated suddenly
     * the queue may no longer be in a usuable state.
     *
     * @throws anything could happen in handler so be prepared!
     */
    public void onClose() throws Exception;

}
